package ControlLayer;

import java.util.ArrayList;

import DBLayer.DBConnection;
import DBLayer.DBPartOrder;
import DBLayer.IFDBPartOrder;
import ModelLayer.PartOrder;
import ModelLayer.Product;
import ModelLayer.SalesOrder;

public class PartOrderCtr {
	
	
	
	public void insertNew(int quantity, String productid, String orderid)
    {    
         PartOrder oObj = new PartOrder();
         oObj.setQuantity(quantity);
         oObj.setProduct(new Product(productid));
         oObj.setOrder(new SalesOrder(orderid));
  
         try{
          DBConnection.startTransaction();
          DBPartOrder dbEmp = new DBPartOrder();
          dbEmp.insert(oObj);
          DBConnection.commitTransaction();
         }
         catch(Exception e)
         {
             DBConnection.rollbackTransaction();
         }
    }
	
	public ArrayList<PartOrder> findAllPartOrder()
    {
      IFDBPartOrder dbP = new DBPartOrder();
      ArrayList<PartOrder> allp = dbP.getAll(false);
      return allp;
    }
}
